home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9043 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: argc/argv & switches
  5. Date: 7 Mar 96 22:34:30 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.826238070@rscernix>
  8. References: <4h2j8j$9gn@milo.freenet.vancouver.bc.ca> <danpop.825593142@rscernix> <313E0094.167EB0E7@fore.com> <4hl52oINNa4l@anvil.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4hl52oINNa4l@anvil.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  13.  
  14. >However, if it were the case that these pointers are not modifiable, 
  15.  
  16. It _is_ the case.  An attempt to modify a pointer from the argv "array" 
  17. results in undefined behaviour.
  18.  
  19. >would not the declaration of main() be required to be written as:
  20. >
  21. >int main(int argc, char * const *argv)
  22. >
  23. >    or
  24. >
  25. >int main(int argc, char * const argv[])
  26. >
  27. >That is, ``argv is a pointer to a vector of constant pointers to modifiable
  28. >chars''.
  29.  
  30. The key point here is backward compatibility with K&R C, which didn't
  31. have the 'const' modifier.
  32.  
  33. A similar case is the type of a string literal, which is char[] and not
  34. const char[], even if you're not allowed to modify a string literal.
  35. The reason is the same: backward compatibility.
  36.  
  37. Dan
  38. --
  39. Dan Pop
  40. CERN, CN Division
  41. Email: danpop@mail.cern.ch 
  42. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  43.